package com.itheima.filter;

import jakarta.servlet.*;
import jakarta.servlet.annotation.WebFilter;

import java.io.IOException;

//@WebFilter("/*")//配置拦截器的拦截路径
public class CemoFilter implements Filter {

    /**
     *  专门进行拦截请求的方法  配置好拦截路径  相关路径都会被拦截住 经过这个方法
     * @param servletRequest  请求对象
     * @param servletResponse 响应对象
     * @param filterChain     放行对象
     * @throws IOException
     * @throws ServletException
     */
    @Override
    public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
        System.out.println("我是Cemo过滤器放行前逻辑");
        filterChain.doFilter(servletRequest, servletResponse);//放行语句 将请求和响应放行过去
        System.out.println("我Cemo过滤器放行后逻辑");
    }

}
